package com.education.platform.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 家长发布需求表
 *
 * @author education-platform
 * @since 2024-09-27
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("demand")
@JsonIgnoreProperties(value = {"handler"})
public class Demand {

    /**
     * 主键ID
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 家长ID
     */
    @TableField("parent_id")
    private Long parentId;

    /**
     * 需求标题
     */
    @TableField("title")
    private String title;

    /**
     * Markdown内容
     */
    @TableField("content_md")
    private String contentMd;

    /**
     * HTML内容
     */
    @TableField("content_html")
    private String contentHtml;

    /**
     * 科目
     */
    @TableField("subject")
    private String subject;

    /**
     * 年级
     */
    @TableField("grade")
    private String grade;

    /**
     * 授课方式
     */
    @TableField("teaching_type")
    private TeachingType teachingType;

    /**
     * 预算最低价
     */
    @TableField("budget_min")
    private BigDecimal budgetMin;

    /**
     * 预算最高价
     */
    @TableField("budget_max")
    private BigDecimal budgetMax;

    /**
     * 期望上课时间
     */
    @TableField("preferred_time")
    private String preferredTime;

    /**
     * 上课地址
     */
    @TableField("address")
    private String address;

    /**
     * 特殊要求
     */
    @TableField("requirements")
    private String requirements;

    /**
     * 附件列表
     */
    @TableField("attachments")
    private String attachments;

    /**
     * 状态
     */
    @TableField("status")
    private String status;

    /**
     * 浏览次数
     */
    @TableField("view_count")
    private Integer viewCount;

    /**
     * 回复次数
     */
    @TableField("reply_count")
    private Integer replyCount;

    /**
     * 过期时间
     */
    @TableField("expires_at")
    private LocalDateTime expiresAt;

    /**
     * 创建时间
     */
    @TableField(value = "created_at", fill = FieldFill.INSERT)
    private LocalDateTime createdAt;

    /**
     * 更新时间
     */
    @TableField(value = "updated_at", fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updatedAt;

    // 关联对象（用于XML映射）
    @TableField(exist = false)
    private User parent;

    // 枚举定义
    public enum TeachingType {
        ONLINE("在线"),
        OFFLINE("线下"),
        BOTH("线上线下均可");

        private final String description;

        TeachingType(String description) {
            this.description = description;
        }

        public String getDescription() {
            return description;
        }
    }

    public enum Status {
        PUBLISHED("已发布"),
        MATCHED("已匹配"),
        CLOSED("已关闭"),
        EXPIRED("已过期");

        private final String description;

        Status(String description) {
            this.description = description;
        }

        public String getDescription() {
            return description;
        }
    }
}
